package com.kethink.clsssify.threadtest;

import java.util.concurrent.Executor;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import java.util.concurrent.ThreadPoolExecutor;

public class ThreadPoolTest {


    public static void main(String[] args){
//        ExecutorService pool = Executors.newFixedThreadPool(3);
//        ExecutorService pool = Executors.newSingleThreadExecutor();
        ExecutorService pool = Executors.newCachedThreadPool();



        for(int i  = 0 ; i < 100 ; i++){
            MyThread t = new MyThread();
            System.out.println("第"+i+"次");
            pool.execute(t);
        }

//        MyThread t1= new MyThread();
//        MyThread t2= new MyThread();
//        MyThread t3= new MyThread();
//        MyThread t4= new MyThread();
//        MyThread t5= new MyThread();
//
//        pool.execute(t1);
//        pool.execute(t2);
//        pool.execute(t3);
//        pool.execute(t4);
//        pool.execute(t5);

//        t1.start();
//        t2.start();
//        t3.start();
//        t4.start();
//        t5.start();

        pool.shutdown();
    }
}
